; Pixel shader used by A3DTerrain2. This shader blend one no-zero terrain layer
; with vertex and lightmap

; t0, layer's normal texture
; t1, layer's mask texture (without alpha channel)
; t2, lightmap texture
; t3, layer's specular texture

ps.1.1

tex t0
tex t1
tex t2
tex t3

mul r1, t3, t3.a	; specular alpha * specular color
mul r1, v1, r1		; multiply vertex color
mul_x2 r1, r1, t2	; multiply lightmap color, do A3DTOP_MODULATE2X effect
mul_x2 r0, t0, t2	; normal texture * multiply lightmap color, do A3DTOP_MODULATE2X effect
add_sat r0, r0, r1
mov r0.a, t1.b